package dreic;

class RegStack {
    private var rsp: Int = 0
    private val MAX: Int = 31
    def fresh: Int = {
        if (rsp < MAX) rsp = rsp + 1
        rsp
    }
    
    def drop: Int = {
        if (rsp > 0) rsp = rsp - 1
        rsp
    }
    
    def top: Int = rsp
    def second: Int = rsp - 1
}
